<template>
	<view class="container">
		<view class="input-container">
			<textarea v-model="inputText" placeholder="请输入要发表的文字动态"></textarea>
		</view>
		<button class="publish-button" @click="publishWord">发表</button>
	</view>
</template>

<style>
	.container {
		width: 80%;
		margin: 80px auto;
		padding: 40px;
		background: linear-gradient(200deg, #99c2ff, #e6f2ff);
		border-radius: 20px;
		box-shadow: 0 10px 25px rgba(0, 102, 204, 0.18);
		display: flex;
		flex-direction: column;
		align-items: center;
		position: relative;
	}

	.input-container {
		width: 100%;
		margin-bottom: 20px;
		position: relative;
		background-color: rgba(255, 255, 255, 0.8);
		backdrop-filter: blur(10px);
		border-radius: 15px;
		padding: 20px;
	}

	.input-container::after {
		content: "";
		position: absolute;
		top: 0;
		right: 0;
		width: 0;
		height: 0;
		border-top: 10px solid transparent;
		border-right: 10px solid #b3d4ff;
		transition: width 0.3s ease, height 0.3s ease;
	}

	.input-container:hover::after {
		width: 100%;
		height: 100%;
	}

	textarea {
		width: 100%;
		height: 180px;
		padding: 15px;
		border: 2px solid transparent;
		border-radius: 10px;
		background-color: white;
		box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
		font-size: 16px;
		resize: none;
		outline: none;
		transition: border 0.3s ease, box-shadow 0.3s ease;
	}

	textarea::-webkit-input-placeholder {
		color: #ccc;
		opacity: 0.7;
	}

	textarea:-moz-placeholder {
		color: #ccc;
		opacity: 0.7;
	}

	textarea::-moz-placeholder {
		color: #ccc;
		opacity: 0.7;
	}

	textarea:-ms-input-placeholder {
		color: #ccc;
		opacity: 0.7;
	}

	textarea:focus {
		border-color: #007aff;
		box-shadow: 0 5px 10px rgba(0, 117, 255, 0.2);
		transform: scale(1.02);
	}

	.publish-button {
		width: 120px;
		height: 45px;
		background-color: #007aff;
		color: white;
		border: none;
		border-radius: 8px;
		font-size: 16px;
		cursor: pointer;
		transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
		box-shadow: 0 6px 12px rgba(0, 102, 204, 0.3), 0 0 0 2px rgba(0, 102, 204, 0.2);
		transform-origin: center;
	}

	.publish-button:hover {
		background-color: #0066cc;
		box-shadow: 0 8px 16px rgba(0, 102, 204, 0.4), 0 0 0 2px rgba(0, 102, 204, 0.3);
	}

	.publish-button:active {
		background-color: #0055aa;
		transform: translateY(2px) scale(0.98);
		box-shadow: 0 4px 8px rgba(0, 102, 204, 0.2), 0 0 0 2px rgba(0, 102, 204, 0.2);
	}
</style>

<script>
	import {
		savecommunity
	} from "@/api/community.js";
	export default {
		data() {
			return {
				inputText: ''
			};
		},
		methods: {
			publishWord() {
				const text = this.inputText;
				if (!text.trim()) {
					uni.showToast({
						title: '请输入内容',
						icon: 'none',
						duration: 1500,
						style: `
                        border: 1px solid #6699cc;
                        background-color: #e6f2ff;
                        color: #333;
                    `
					});
					return;
				}
				const data = {
					content: this.inputText
				}
				savecommunity(data).then(res => {
					uni.showToast({
						title: '发表成功',
						icon: 'success',
						duration: 1500,
						style: `
					        border: 1px solid #6699cc;
					        background-color: #e6f2ff;
					        color: #333;
					    `
					});
				})
				this.inputText = '';
			}
		}
	};
</script>